package com.jzo2o.foundations.controller.operation;

import com.baomidou.mybatisplus.extension.service.IService;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.IServeItemService;
import com.jzo2o.foundations.service.IServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import nonapi.io.github.classgraph.utils.LogNode;
import org.jboss.marshalling.OutputStreamByteOutput;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * 区域服务相关接口
 * @Author wd
 * @Date 2025/6/30 17:19
 */

@RestController("operationServiceController")
@RequestMapping("/operation/serve")
@Api(tags = "运营端-区域服务相关接口")
public class ServeController {

    @Autowired
    private IServeService serveService;

    @GetMapping("/page")
    @ApiOperation("服务分页查询")
    public PageResult<ServeResDTO> page(ServePageQueryReqDTO dto) {
        return serveService.pageList(dto);
    }

    @PostMapping("/batch")
    @ApiOperation("批量新增区域服务")
    public void batchAdd(@RequestBody List<ServeUpsertReqDTO> dtoList){
        serveService.batchAdd(dtoList);
    }

    @PutMapping("/{id}")
    @ApiOperation("修改区域服务价格")
    public void updatePrice(@PathVariable("id") Long id,@RequestParam("price") BigDecimal price ){
        serveService.updatePrice(id, price);
    }

    @PutMapping("/onSale/{id}")
    @ApiOperation("区域服务上架")
    public void onSale(@PathVariable("id") Long id) {
        serveService.onSale(id);
    }
}
